#include "krtpch.h"

#include <memory>

#include "../../include/Accel/ListAccel.h"

namespace krt {

	bool ListAccel::Intersect(const Ray& r, Intersection& rec) const {
		Intersection recTmp;
		bool isHited = false;
		Ray ray = r;
		float tHit;
		for (auto& hit : m_Data) {
			if (hit->Intersect(ray, recTmp)) {
				isHited = true;
				rec = recTmp;
			}
		}
		return isHited;
	}

	bool ListAccel::AddHitable(Ref<Primitive> hitable) {
		m_Data.push_back(hitable);
		return true;
	}

}